import { ResPage, Product } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";
import qs from "qs";

/**
 * @name 商品管理模块
 */

// 获取商品列表
export const getProductList = (params: Product.ResProductList) => {
  return http.post<ResPage<Product.ResProductList>>(PORT1 + `/CoreCmsGoods/GetPageList`, qs.stringify(params));
};

// 获取商品品牌列表
export const getProductBrandList = (params: Product.ResBrandList) => {
  return http.post<ResPage<Product.ResBrandList>>(PORT1 + `/CoreCmsBrand/GetPageList`, qs.stringify(params));
};

// 切换商品上/下架状态
export const changeProductStatus = (params: { id: string; data: boolean }) => {
  return http.post(PORT1 + `/CoreCmsGoods/DoSetisMarketable`, params);
};

// 新增商品
export const addProduct = (params: { id: string }) => {
  return http.post(PORT1 + `/CoreCmsGoods/GetCreate`, params);
};

// 编辑商品
export const editProduct = (params: { id: string }) => {
  return http.post(PORT1 + `/CoreCmsGoods/DoEdit`, params);
};

// 删除商品
export const deleteProduct = (params: { id: string }) => {
  return http.post(PORT1 + `/CoreCmsGoods/DoDelete`, params);
};

// 批量删除商品
export const batchDeleteProduct = (params: { id: string[] }) => {
  return http.post(PORT1 + `/CoreCmsGoods/DoBatchDelete`, params);
};

// 新增商品品牌
export const addProductBrand = (params: { id: string }) => {
  return http.post(PORT1 + `/CoreCmsBrand/DoCreate`, params);
};

// 编辑商品品牌
export const editProductBrand = (params: { id: string }) => {
  return http.post(PORT1 + `/CoreCmsBrand/DoEdit`, params);
};

// 删除商品品牌
export const deleteProductBrand = (params: { id: string }) => {
  return http.post(PORT1 + `/CoreCmsBrand/DoDelete`, params);
};

// 切换品牌显示状态
export const changeBrandShow = (params: { id: string; data: boolean }) => {
  return http.post(PORT1 + `/CoreCmsBrand/DoSetisShow`, params);
};

// 获取商品分类列表
export const getProductCategoryList = (params: Product.ResCategoryList) => {
  return http.post<ResPage<Product.ResCategoryList>>(PORT1 + `/CoreCmsGoodsCategory/GetPageList`, qs.stringify(params));
};

// 新增商品分类
export const addProductCategory = (params: { id: string }) => {
  return http.post(PORT1 + `/CoreCmsGoodsCategory/DoCreate`, params);
};

// 编辑商品分类
export const editProductCategory = (params: { id: string }) => {
  return http.post(PORT1 + `/CoreCmsGoodsCategory/DoEdit`, params);
};

// 删除商品分类
export const deleteProductCategory = (params: { id: string }) => {
  return http.post(PORT1 + `/CoreCmsGoodsCategory/DoDelete`, params);
};

// 删除商品分类
export const changeCategoryShow = (params: { id: string; data: boolean }) => {
  return http.post(PORT1 + `/CoreCmsGoodsCategory/DoSetisShow`, params);
};

// 删除商品分类
export const getCategoryDictionary = () => {
  return http.post(PORT1 + `/CoreCmsGoodsCategory/GetCreate`);
};
